﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="RoleEditor.aspx.cs" Inherits="Atomic.Web.Pages.Sys.RoleEditor" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <script type="text/javascript" language="javascript">
        $(function () {
            var box = $('#roleEditorForm');
            var ID = '<%=Request["ID"] %>'; //预编辑项ID

            //预编辑加载
            if (ID > 0) {
                //角色
                $.post('/Handlers/Sys/RoleHandler.ashx/?method=GetRole',
                {
                    ID: ID
                },
                function (data) {
                    if (data != null) {
                        $('#Name', box).val(data.Name);
                        $('#Enabled', box).attr('checked', data.Enabled == '1');
                        $('#Description', box).val(data.Description);
                    }
                },
                'json');
            }

            //保存事件
            $('#btnSubmit').linkbutton().click(function () {
                $.post('/Handlers/Sys/RoleHandler.ashx/?method=AddRole',
                {
                    ID: ID,
                    Name: $('#Name', box).val(),
                    Enabled: $('#Enabled', box).attr('checked') ? 1 : 0,
                    Description: $('#Description', box).val()
                },
                function (data) {
                    if (data.Success) {
                        try {
                            OnRoleEditSuccess();
                        } catch (e) {
                        }
                    } else {
                        $.messager.alert('提示信息', data.Message, 'warning');
                    }
                },
                'json');
            });
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <table id="roleEditorForm">
        <tr>
            <td>
                角色名
            </td>
            <td>
                <input type="text" id="Name" value="" class="easyui-validatebox" required="true" />
            </td>
        </tr>
        <tr>
            <td>
                启用
            </td>
            <td>
                <input type="checkbox" id="Enabled" />
            </td>
        </tr>
        <tr>
            <td>
                描述
            </td>
            <td>
                <textarea id="Description" style="height: 50px;"></textarea>
            </td>
        </tr>
        <tr>
            <td>
            </td>
            <td>
                <a id="btnSubmit" href="javascript:void(0);">提 交</a>
            </td>
        </tr>
    </table>
    </form>
</body>
</html>
